package cn.tk.service.log.customer;

import cn.tk.model.entity.mr.OutcallCollect;
import cn.tk.service.log.queue.OutcallCollectQueue;
import cn.tk.service.mr.OutcallCollectService;
import lombok.extern.slf4j.Slf4j;

/**
 * Created by denglw on 2019/7/31.<br/>
 * Desc: 外呼信息采集  消费者
 */
@Slf4j
public class OutcallCollectCustomer extends BaseCustomer<OutcallCollectQueue, OutcallCollectService> {

    public OutcallCollectCustomer(OutcallCollectQueue queue, OutcallCollectService service) {
        super(queue, service);
    }

    @Override
    public void start() {
        while (true) {
            if (service == null) {
                log.error("外呼信息采集服务层为空.");
                break;
            }
            OutcallCollect collect;
            try {
                collect = queue.take();
                if (collect != null) {
                    service.save(collect);
                }
            } catch (Exception e) {
                log.error("外呼信息采集入库队列异常中断: [{}].", e.getMessage());
                e.printStackTrace();
            }
        }
    }

}
